How to use eliot - 10 common examples

To help you get started, we’ve selected a few eliot 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 ClusterHQ / flocker / flocker / acceptance / testtools.py View on Github external
def cleanup_leases():
            context = start_action(action_type="acceptance:cleanup_leases")
            with context.context():
                get_items = DeferredContext(self.client.list_leases())

                def release_all(leases):
                    release_list = []
                    for lease in leases:
                        release_list.append(
                            self.client.release_lease(lease.dataset_id))
                    return gather_deferreds(release_list)

                get_items.addCallback(release_all)
                releasing_leases = get_items.addActionFinish()
                return timeout(
                    reactor, releasing_leases, 20,
                    Exception("Timed out cleaning up leases"),
                )
github twisted / txacme / src / integration / test_client.py View on Github external
def _test_register(self, new_reg=None):
        with start_action(action_type=u'integration:register').context():
            return (
                DeferredContext(self.client.register(new_reg))
                .addActionFinish())
github twisted / txacme / src / integration / test_client.py View on Github external
def _test_poll_pending(self, auth):
        action = start_action(action_type=u'integration:poll_pending')
        with action.context():
            return (
                DeferredContext(self.client.poll(auth))
                .addCallback(
                    lambda auth:
                    self.assertEqual(auth[0].body.status, STATUS_PENDING))
                .addActionFinish())
github ClusterHQ / flocker / flocker / acceptance / testtools.py View on Github external
def failed(failure):
            Message.new(message_type=u"acceptance:http_query_failed",
                        reason=unicode(failure)).write()
            return False
        req.addCallbacks(content, failed)
github ClusterHQ / flocker / flocker / acceptance / endtoend / test_installer.py View on Github external
def wait_for_stack_status(stack_id, target_status):
    """
    Poll the status of a CloudFormation stack.

    :param unicode stack_id: The AWS cloudformation stack ID.
    :param unicode target_status: The desired stack status.
    :returns: A ``Deferred`` which fires when the stack has ``target_status``.
    """
    Message.log(
        function='wait_for_stack_status',
        stack_id=stack_id,
        target_status=target_status,
    )

    def predicate():
        stack_report = get_stack_report(stack_id)
        current_status = stack_report['StackStatus']
        if current_status == target_status:
            return stack_report

    return loop_until(reactor, predicate, repeat(10, 60))
github ClusterHQ / flocker / flocker / acceptance / testtools.py View on Github external
def failed(failure):
            Message.new(message_type=u"acceptance:http_query_failed",
                        reason=unicode(failure)).write()
            return False
        request.addCallbacks(content, failed)
github ClusterHQ / flocker / flocker / node / testtools.py View on Github external
``IDeployer`` being tested.
    :param Leases leases: Currently configured leases. By default none exist.
    """
    cluster_state = compute_cluster_state(node_state, additional_node_states,
                                          nonmanifest_datasets)
    cluster_configuration = Deployment(
        nodes={node_config} | additional_node_config,
        leases=leases,
    )
    changes = deployer.calculate_changes(
        cluster_configuration, cluster_state, local_state
    )
    case.assertEqual(expected_changes, changes)


ADDRESS_IN_USE = MessageType(
    u"flocker:test:address_in_use",
    fields(ip=unicode, port=int, name=bytes),
)


def _find_process_name(port_number):
    """
    Get the name of the process using the given port number.
    """
    for connection in psutil.net_connections():
        if connection.laddr[1] == port_number:
            return psutil.Process(connection.pid).name()
    return None


def _retry_on_port_collision(reason, add, cleanup):
github ClusterHQ / flocker / flocker / acceptance / testtools.py View on Github external
def failed_query(failure):
            reasons = getattr(failure.value, 'reasons', None)
            if reasons is None:
                # Guess it was something else.  Do some simpler logging.
                write_failure(failure, logger=None)
            else:
                # It is one of those.  Log all of the stuff from inside it.
                for reason in reasons:
                    write_failure(reason, logger=None)
            return False
        d = cluster.current_nodes()
github ClusterHQ / flocker / flocker / acceptance / testtools.py View on Github external
def failed_query(failure):
            reasons = getattr(failure.value, 'reasons', None)
            if reasons is None:
                # Guess it was something else.  Do some simpler logging.
                write_failure(failure, logger=None)
            else:
                # It is one of those.  Log all of the stuff from inside it.
                for reason in reasons:
                    write_failure(reason, logger=None)
            return False
        d = cluster.current_nodes()
github ClusterHQ / flocker / flocker / acceptance / testtools.py View on Github external
def failed_query(failure):
            reasons = getattr(failure.value, 'reasons', None)
            if reasons is None:
                # Guess it was something else.  Do some simpler logging.
                write_failure(failure, logger=None)
            else:
                # It is one of those.  Log all of the stuff from inside it.
                for reason in reasons:
                    write_failure(reason, logger=None)
            return False
        d = cluster.current_nodes()