Example #1
0
def test_tls_publish():
    extra_params = [
        '--tls-required', 'true',
        '--https-address', '127.0.0.1:4152',
    ]
    with NsqdIntegrationServer(extra_params=extra_params) as server:
        producer = Producer(
            server.tcp_address,
            tls_options={
                'keyfile': server.tls_key,
                'certfile': server.tls_cert,
            },
            tls_v1=True,
        )
        producer.start()

        for _ in range(100):
            producer.publish('test', b'hi')

        producer.close()
        producer.join()

        conn = NsqdHTTPClient(
            server.address,
            '4152',
            connection_class=urllib3.HTTPSConnectionPool,
            cert_reqs='CERT_NONE',
        )
        stats = conn.stats()

        assert stats['topics'][0]['depth'] == 100
Example #2
0
def test_publish_error():
    with NsqdIntegrationServer() as server:
        producer = Producer(server.tcp_address)
        producer.start()

        with pytest.raises(NSQInvalid):
            producer.publish('test', b'hi', defer=-1000)

        producer.close()
        producer.join()
Example #3
0
def test_publish_error():
    with NsqdIntegrationServer() as server:
        producer = Producer(server.tcp_address)
        producer.start()

        with pytest.raises(NSQInvalid):
            producer.publish('test', b'hi', defer=-1000)

        producer.close()
        producer.join()
Example #4
0
def test_multipublish():
    with NsqdIntegrationServer() as server:
        producer = Producer(server.tcp_address)
        producer.start()

        for _ in range(10):
            producer.multipublish('test', 10 * [b'hi'])

        producer.close()
        producer.join()

        conn = NsqdHTTPClient(server.address, server.http_port)
        stats = conn.stats()

        assert stats['topics'][0]['depth'] == 100
Example #5
0
def test_multipublish():
    with NsqdIntegrationServer() as server:
        producer = Producer(server.tcp_address)
        producer.start()

        for _ in range(10):
            producer.multipublish('test', 10 * [b'hi'])

        producer.close()
        producer.join()

        conn = NsqdHTTPClient(server.address, server.http_port)
        stats = conn.stats()

        assert stats['topics'][0]['depth'] == 100
Example #6
0
def test_async_publish():
    with NsqdIntegrationServer() as server:
        results = []
        producer = Producer(server.tcp_address)
        producer.start()

        for _ in range(100):
            results.append(producer.publish('test', b'hi', raise_error=False))

        gevent.joinall(results, raise_error=True)
        producer.close()
        producer.join()

        conn = NsqdHTTPClient(server.address, server.http_port)
        stats = conn.stats()

        assert stats['topics'][0]['depth'] == 100
Example #7
0
def test_async_publish():
    with NsqdIntegrationServer() as server:
        results = []
        producer = Producer(server.tcp_address)
        producer.start()

        for _ in range(100):
            results.append(producer.publish('test', b'hi', raise_error=False))

        gevent.joinall(results, raise_error=True)
        producer.close()
        producer.join()

        conn = NsqdHTTPClient(server.address, server.http_port)
        stats = conn.stats()

        assert stats['topics'][0]['depth'] == 100