How to use the rally.task.atomic.ActionTimer function in rally

To help you get started, we’ve selected a few rally examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / rally / tests / unit / task / test_atomic.py View on Github external
def test_action_timer_context(self, mock_time):
        inst = atomic.ActionTimerMixin()

        with atomic.ActionTimer(inst, "test"):
            with atomic.ActionTimer(inst, "test"):
                with atomic.ActionTimer(inst, "some"):
                    pass

        expected = [{"name": "test",
                     "started_at": 1,
                     "finished_at": 21,
                     "children": [{"name": "test",
                                   "started_at": 3,
                                   "finished_at": 15,
                                   "children": [{"name": "some",
                                                 "started_at": 6,
                                                 "finished_at": 10,
                                                 "children": []}]}]}]
        self.assertEqual(expected,
                         inst.atomic_actions())
github openstack / rally-openstack / rally_openstack / scenarios / vm / utils.py View on Github external
def _delete_floating_ip(self, server, fip):
        with logging.ExceptionLogger(
                LOG, "Unable to delete IP: %s" % fip["ip"]):
            if self.check_ip_address(fip["ip"])(server):
                self._dissociate_floating_ip(server, fip)
                with atomic.ActionTimer(self, "neutron.delete_floating_ip"):
                    network_wrapper.wrap(self.clients,
                                         self).delete_floating_ip(
                        fip["id"], wait=True)
github openstack / rally-openstack / rally_openstack / scenarios / nova / utils.py View on Github external
"""
        image_uuid = self.clients("nova").servers.create_image(server,
                                                               server.name)
        glance = image_service.Image(self._clients,
                                     atomic_inst=self.atomic_actions())
        image = glance.get_image(image_uuid)
        check_interval = CONF.openstack.nova_server_image_create_poll_interval
        with atomic.ActionTimer(self, "glance.wait_for_image"):
            image = utils.wait_for_status(
                image,
                ready_statuses=["ACTIVE"],
                update_resource=glance.get_image,
                timeout=CONF.openstack.nova_server_image_create_timeout,
                check_interval=check_interval
            )
        with atomic.ActionTimer(self, "nova.wait_for_server"):
            utils.wait_for_status(
                server,
                ready_statuses=["None"],
                status_attr="OS-EXT-STS:task_state",
                update_resource=utils.get_from_manager(),
                timeout=CONF.openstack.nova_server_image_create_timeout,
                check_interval=check_interval
            )
        return image
github xrally / xrally-kubernetes / xrally_kubernetes / service.py View on Github external
name = self.generate_random_name()

        manifest = {
            "apiVersion": "v1",
            "kind": "Namespace",
            "metadata": {
                "name": name,
                "labels": {
                    "role": name
                }
            }
        }
        self.v1_client.create_namespace(body=manifest)

        if status_wait:
            with atomic.ActionTimer(self,
                                    "kubernetes.wait_for_nc_become_active"):
                wait_for_status(name,
                                resource_type="Namespace",
                                status="Active",
                                read_method=self.get_namespace)
        return name
github openstack / rally-openstack / rally_openstack / services / storage / cinder_common.py View on Github external
def create_encryption_type(self, volume_type, specs):
        """Create encryption type for a volume type. Default: admin only.

        :param volume_type: the volume type on which to add an encryption type
        :param specs: the encryption type specifications to add
        :return: an instance of :class: VolumeEncryptionType
        """
        aname = "cinder_v%s.create_encryption_type" % self.version
        with atomic.ActionTimer(self, aname):
            return self._get_client().volume_encryption_types.create(
                volume_type, specs)
github openstack / rally-openstack / rally_openstack / services / storage / cinder_common.py View on Github external
def transfer_accept(self, transfer_id, auth_key):
        """Accept a volume transfer.

        :param transfer_id: The ID of the transfer to accept.
        :param auth_key: The auth_key of the transfer.
        :rtype: VolumeTransfer
        """
        aname = "cinder_v%s.transfer_accept" % self.version
        with atomic.ActionTimer(self, aname):
            return self._get_client().transfers.accept(transfer_id, auth_key)
github openstack / ec2-api / rally-scenarios / plugins / ec2api_plugin.py View on Github external
def describe_subnets_neutron(self):
        neutron = osclients.Clients(
            self.context['user']['credential']).neutron()
        project_id = self.context["tenant"]["id"]
        with atomic.ActionTimer(self, 'describe_subnets_neutron'):
            neutron.list_subnets(tenant_id=project_id)
github openstack / rally / rally / plugins / openstack / scenarios / authenticate / authenticate.py View on Github external
def run(self, repetitions):
        """Check Neutron Client to ensure validation of token.

        Creation of the client does not ensure validation of the token.
        We have to do some minimal operation to make sure token gets validated.

        :param repetitions: number of times to validate
        """
        neutron_client = self.clients("neutron")
        with atomic.ActionTimer(
                self,
                "authenticate.validate_neutron_%s_times" % repetitions):
            for i in range(repetitions):
                neutron_client.list_networks()
github openstack / rally / rally / plugins / openstack / scenarios / heat / stacks.py View on Github external
def run(self):
        """List events from tenant stacks."""
        stacks = self._list_stacks()
        for stack in stacks:
            with atomic.ActionTimer(self, "heat.list_events"):
                self.clients("heat").events.list(stack.id)
github openstack / rally-openstack / rally_openstack / scenarios / heat / stacks.py View on Github external
def run(self):
        """List events from tenant stacks."""
        stacks = self._list_stacks()
        for stack in stacks:
            with atomic.ActionTimer(self, "heat.list_events"):
                self.clients("heat").events.list(stack.id)