示例#1
0
receive test.
"""

import logging
import asyncio
import argparse
import time
import os
from urllib.parse import quote_plus

from azure.eventhub import Offset
from azure.eventhub.async import EventHubClientAsync

try:
    import tests
    logger = tests.get_logger("recv_test.log", logging.INFO)
except ImportError:
    logger = logging.getLogger("uamqp")
    logger.setLevel(logging.INFO)


async def pump(_pid, receiver, _args, _dl):
    total = 0
    iteration = 0
    deadline = time.time() + _dl
    try:
        while time.time() < deadline:
            batch = await receiver.receive(timeout=5)
            size = len(batch)
            total += size
            iteration += 1
import sys

from tests import get_logger
from azure import eventhub
from azure.eventhub import EventHubClient, Receiver, Offset
from azure.eventprocessorhost import EventProcessorHost
from azure.eventprocessorhost import EventHubPartitionPump
from azure.eventprocessorhost import AzureStorageCheckpointLeaseManager
from azure.eventprocessorhost import AzureBlobLease
from azure.eventprocessorhost import EventHubConfig
from azure.eventprocessorhost.lease import Lease
from azure.eventprocessorhost.partition_pump import PartitionPump
from azure.eventprocessorhost.partition_manager import PartitionManager
from azure.eventprocessorhost.abstract_event_processor import AbstractEventProcessor

log = get_logger(None, logging.DEBUG)


@pytest.fixture()
def live_eventhub_config():
    try:
        config = {}
        config['hostname'] = os.environ['EVENT_HUB_HOSTNAME']
        config['event_hub'] = os.environ['EVENT_HUB_NAME']
        config['key_name'] = os.environ['EVENT_HUB_SAS_POLICY']
        config['access_key'] = os.environ['EVENT_HUB_SAS_KEY']
        config['consumer_group'] = "$Default"
        config['partition'] = "0"
    except KeyError:
        pytest.skip("Live EventHub configuration not found.")
    else:
"""
send test
"""

import logging
import argparse
import time
import threading
import os
import asyncio

from azure.eventhub import EventHubClientAsync, EventData

try:
    import tests
    logger = tests.get_logger("send_test.log", logging.INFO)
except ImportError:
    logger = logging.getLogger("uamqp")
    logger.setLevel(logging.INFO)


def check_send_successful(outcome, condition):
    if outcome.value != 0:
        print("Send failed {}".format(condition))


async def get_partitions(args):
    #client = EventHubClientAsync.from_connection_string(
    #    args.conn_str,
    #    eventhub=args.eventhub, debug=True)
    eh_data = await args.get_eventhub_info_async()
示例#4
0
import sys

from tests import get_logger
from azure import eventhub
from azure.eventhub import EventHubClient, Receiver, Offset
from azure.eventprocessorhost import EventProcessorHost
from azure.eventprocessorhost import EventHubPartitionPump
from azure.eventprocessorhost import AzureStorageCheckpointLeaseManager
from azure.eventprocessorhost import AzureBlobLease
from azure.eventprocessorhost import EventHubConfig
from azure.eventprocessorhost.lease import Lease
from azure.eventprocessorhost.partition_pump import PartitionPump
from azure.eventprocessorhost.partition_manager import PartitionManager
from azure.eventprocessorhost.abstract_event_processor import AbstractEventProcessor

log = get_logger(None, logging.INFO)


@pytest.fixture()
def live_eventhub_config():
    try:
        config = {}
        config['hostname'] = os.environ['EVENT_HUB_HOSTNAME']
        config['event_hub'] = os.environ['EVENT_HUB_NAME']
        config['key_name'] = os.environ['EVENT_HUB_SAS_POLICY']
        config['access_key'] = os.environ['EVENT_HUB_SAS_KEY']
        config['consumer_group'] = "$Default"
        config['partition'] = "0"
    except KeyError:
        pytest.skip("Live EventHub configuration not found.")
    else: