http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2afe2ec0/tests/python/proton_tests/soak.py ---------------------------------------------------------------------- diff --git a/tests/python/proton_tests/soak.py b/tests/python/proton_tests/soak.py deleted file mode 100644 index 52382ba..0000000 --- a/tests/python/proton_tests/soak.py +++ /dev/null @@ -1,368 +0,0 @@ -from __future__ import absolute_import -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -import os -import sys -from .common import Test, Skipped, free_tcp_ports, \ - MessengerReceiverC, MessengerSenderC, \ - MessengerReceiverValgrind, MessengerSenderValgrind, \ - MessengerReceiverPython, MessengerSenderPython, \ - ReactorReceiverC, ReactorSenderC, \ - ReactorReceiverValgrind, ReactorSenderValgrind, \ - isSSLPresent -from proton import * - -# -# Tests that run the apps -# - -class AppTests(Test): - - def __init__(self, *args): - Test.__init__(self, *args) - self.is_valgrind = False - - def default(self, name, value, **kwargs): - if self.is_valgrind: - default = kwargs.get("valgrind", value) - else: - default = value - return Test.default(self, name, default, **kwargs) - - @property - def iterations(self): - return int(self.default("iterations", 2, fast=1, valgrind=2)) - - @property - def send_count(self): - return int(self.default("send_count", 17, fast=1, valgrind=2)) - - @property - def target_count(self): - return int(self.default("target_count", 5, fast=1, valgrind=2)) - - @property - def send_batch(self): - return int(self.default("send_batch", 7, fast=1, valgrind=2)) - - @property - def forward_count(self): - return int(self.default("forward_count", 5, fast=1, valgrind=2)) - - @property - def port_count(self): - return int(self.default("port_count", 3, fast=1, valgrind=2)) - - @property - def sender_count(self): - return int(self.default("sender_count", 3, fast=1, valgrind=2)) - - def valgrind_test(self): - self.is_valgrind = True - - def setUp(self): - self.senders = [] - self.receivers = [] - - def tearDown(self): - pass - - def _do_test(self, iterations=1): - verbose = self.verbose - - for R in self.receivers: - R.start( verbose ) - - for j in range(iterations): - for S in self.senders: - S.start( verbose ) - - for S in self.senders: - S.wait() - #print("SENDER OUTPUT:") - #print( S.stdout() ) - assert S.status() == 0, ("Command '%s' failed status=%d: '%s' '%s'" - % (str(S.cmdline()), - S.status(), - S.stdout(), - S.stderr())) - - for R in self.receivers: - R.wait() - #print("RECEIVER OUTPUT") - #print( R.stdout() ) - assert R.status() == 0, ("Command '%s' failed status=%d: '%s' '%s'" - % (str(R.cmdline()), - R.status(), - R.stdout(), - R.stderr())) - -# -# Traffic passing tests based on the Messenger apps -# - -class MessengerTests(AppTests): - - _timeout = 60 - - def _ssl_check(self): - if not isSSLPresent(): - raise Skipped("No SSL libraries found.") - if os.name=="nt": - raise Skipped("Windows SChannel lacks anonymous cipher support.") - - def __init__(self, *args): - AppTests.__init__(self, *args) - - def _do_oneway_test(self, receiver, sender, domain="amqp"): - """ Send N messages to a receiver. - Parameters: - iterations - repeat the senders this many times - target_count = # of targets to send to. - send_count = # messages sent to each target - """ - iterations = self.iterations - send_count = self.send_count - target_count = self.target_count - - send_total = send_count * target_count - receive_total = send_total * iterations - - port = free_tcp_ports()[0] - - receiver.subscriptions = ["%s://~0.0.0.0:%s" % (domain, port)] - receiver.receive_count = receive_total - receiver.timeout = MessengerTests._timeout - self.receivers.append( receiver ) - - sender.targets = ["%s://0.0.0.0:%s/X%d" % (domain, port, j) for j in range(target_count)] - sender.send_count = send_total - sender.timeout = MessengerTests._timeout - self.senders.append( sender ) - - self._do_test(iterations) - - def _do_echo_test(self, receiver, sender, domain="amqp"): - """ Send N messages to a receiver, which responds to each. - Parameters: - iterations - repeat the senders this many times - target_count - # targets to send to - send_count = # messages sent to each target - send_batch - wait for replies after this many messages sent - """ - iterations = self.iterations - send_count = self.send_count - target_count = self.target_count - send_batch = self.send_batch - - send_total = send_count * target_count - receive_total = send_total * iterations - - port = free_tcp_ports()[0] - - receiver.subscriptions = ["%s://~0.0.0.0:%s" % (domain, port)] - receiver.receive_count = receive_total - receiver.send_reply = True - receiver.timeout = MessengerTests._timeout - self.receivers.append( receiver ) - - sender.targets = ["%s://0.0.0.0:%s/%dY" % (domain, port, j) for j in range(target_count)] - sender.send_count = send_total - sender.get_reply = True - sender.send_batch = send_batch - sender.timeout = MessengerTests._timeout - self.senders.append( sender ) - - self._do_test(iterations) - - def _do_relay_test(self, receiver, relay, sender, domain="amqp"): - """ Send N messages to a receiver, which replies to each and forwards - each of them to different receiver. - Parameters: - iterations - repeat the senders this many times - target_count - # targets to send to - send_count = # messages sent to each target - send_batch - wait for replies after this many messages sent - forward_count - forward to this many targets - """ - iterations = self.iterations - send_count = self.send_count - target_count = self.target_count - send_batch = self.send_batch - forward_count = self.forward_count - - send_total = send_count * target_count - receive_total = send_total * iterations - - port = free_tcp_ports()[0] - - receiver.subscriptions = ["%s://~0.0.0.0:%s" % (domain, port)] - receiver.receive_count = receive_total - receiver.send_reply = True - # forward to 'relay' - uses two links - # ## THIS FAILS: - # receiver.forwards = ["amqp://Relay/%d" % j for j in range(forward_count)] - receiver.forwards = ["%s://Relay" % domain] - receiver.timeout = MessengerTests._timeout - self.receivers.append( receiver ) - - relay.subscriptions = ["%s://0.0.0.0:%s" % (domain, port)] - relay.name = "Relay" - relay.receive_count = receive_total - relay.timeout = MessengerTests._timeout - self.receivers.append( relay ) - - # send to 'receiver' - sender.targets = ["%s://0.0.0.0:%s/X%dY" % (domain, port, j) for j in range(target_count)] - sender.send_count = send_total - sender.get_reply = True - sender.timeout = MessengerTests._timeout - self.senders.append( sender ) - - self._do_test(iterations) - - - def _do_star_topology_test(self, r_factory, s_factory, domain="amqp"): - """ - A star-like topology, with a central receiver at the hub, and senders at - the spokes. Each sender will connect to each of the ports the receiver is - listening on. Each sender will then create N links per each connection. - Each sender will send X messages per link, waiting for a response. - Parameters: - iterations - repeat the senders this many times - port_count - # of ports the receiver will listen on. Each sender connects - to all ports. - sender_count - # of senders - target_count - # of targets per connection - send_count - # of messages sent to each target - send_batch - # of messages to send before waiting for response - """ - iterations = self.iterations - port_count = self.port_count - sender_count = self.sender_count - target_count = self.target_count - send_count = self.send_count - send_batch = self.send_batch - - send_total = port_count * target_count * send_count - receive_total = send_total * sender_count * iterations - - ports = free_tcp_ports(port_count) - - receiver = r_factory() - receiver.subscriptions = ["%s://~0.0.0.0:%s" % (domain, port) for port in ports] - receiver.receive_count = receive_total - receiver.send_reply = True - receiver.timeout = MessengerTests._timeout - self.receivers.append( receiver ) - - for i in range(sender_count): - sender = s_factory() - sender.targets = ["%s://0.0.0.0:%s/%d" % (domain, port, j) for port in ports for j in range(target_count)] - sender.send_count = send_total - sender.send_batch = send_batch - sender.get_reply = True - sender.timeout = MessengerTests._timeout - self.senders.append( sender ) - - self._do_test(iterations) - - def test_oneway_C(self): - self._do_oneway_test(MessengerReceiverC(), MessengerSenderC()) - - def test_oneway_C_SSL(self): - self._ssl_check() - self._do_oneway_test(MessengerReceiverC(), MessengerSenderC(), "amqps") - - def test_oneway_valgrind(self): - self.valgrind_test() - self._do_oneway_test(MessengerReceiverValgrind(), MessengerSenderValgrind()) - - def test_oneway_Python(self): - self._do_oneway_test(MessengerReceiverPython(), MessengerSenderPython()) - - def test_oneway_C_Python(self): - self._do_oneway_test(MessengerReceiverC(), MessengerSenderPython()) - - def test_oneway_Python_C(self): - self._do_oneway_test(MessengerReceiverPython(), MessengerSenderC()) - - def test_echo_C(self): - self._do_echo_test(MessengerReceiverC(), MessengerSenderC()) - - def test_echo_C_SSL(self): - self._ssl_check() - self._do_echo_test(MessengerReceiverC(), MessengerSenderC(), "amqps") - - def test_echo_valgrind(self): - self.valgrind_test() - self._do_echo_test(MessengerReceiverValgrind(), MessengerSenderValgrind()) - - def test_echo_Python(self): - self._do_echo_test(MessengerReceiverPython(), MessengerSenderPython()) - - def test_echo_C_Python(self): - self._do_echo_test(MessengerReceiverC(), MessengerSenderPython()) - - def test_echo_Python_C(self): - self._do_echo_test(MessengerReceiverPython(), MessengerSenderC()) - - def test_relay_C(self): - self._do_relay_test(MessengerReceiverC(), MessengerReceiverC(), MessengerSenderC()) - - def test_relay_C_SSL(self): - self._ssl_check() - self._do_relay_test(MessengerReceiverC(), MessengerReceiverC(), MessengerSenderC(), "amqps") - - def test_relay_valgrind(self): - self.valgrind_test() - self._do_relay_test(MessengerReceiverValgrind(), MessengerReceiverValgrind(), MessengerSenderValgrind()) - - def test_relay_C_Python(self): - self._do_relay_test(MessengerReceiverC(), MessengerReceiverPython(), MessengerSenderPython()) - - def test_relay_Python(self): - self._do_relay_test(MessengerReceiverPython(), MessengerReceiverPython(), MessengerSenderPython()) - - def test_star_topology_C(self): - self._do_star_topology_test( MessengerReceiverC, MessengerSenderC ) - - def test_star_topology_C_SSL(self): - self._ssl_check() - self._do_star_topology_test( MessengerReceiverC, MessengerSenderC, "amqps" ) - - def test_star_topology_valgrind(self): - self.valgrind_test() - self._do_star_topology_test( MessengerReceiverValgrind, MessengerSenderValgrind ) - - def test_star_topology_Python(self): - self._do_star_topology_test( MessengerReceiverPython, MessengerSenderPython ) - - def test_star_topology_Python_C(self): - self._do_star_topology_test( MessengerReceiverPython, MessengerSenderC ) - - def test_star_topology_C_Python(self): - self._do_star_topology_test( MessengerReceiverPython, MessengerSenderC ) - - def test_oneway_reactor(self): - self._do_oneway_test(ReactorReceiverC(), ReactorSenderC()) - - def test_oneway_reactor_valgrind(self): - self.valgrind_test() - self._do_oneway_test(ReactorReceiverValgrind(), ReactorSenderValgrind())
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2afe2ec0/tests/python/proton_tests/ssl.py ---------------------------------------------------------------------- diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py index 89fe828..225afa7 100644 --- a/tests/python/proton_tests/ssl.py +++ b/tests/python/proton_tests/ssl.py @@ -832,93 +832,6 @@ class SslTest(common.Test): assert server.connection.state & Endpoint.REMOTE_UNINIT self.tearDown() - def test_defaults_messenger_app(self): - """ Test an SSL connection using the Messenger apps (no certificates) - """ - if os.name=="nt": - raise Skipped("Windows SChannel lacks anonymous cipher support.") - port = common.free_tcp_ports()[0] - - receiver = common.MessengerReceiverC() - receiver.subscriptions = ["amqps://~0.0.0.0:%s" % port] - receiver.receive_count = 1 - receiver.timeout = self.timeout - receiver.start() - - sender = common.MessengerSenderC() - sender.targets = ["amqps://0.0.0.0:%s/X" % port] - sender.send_count = 1 - sender.timeout = self.timeout - sender.start() - sender.wait() - assert sender.status() == 0, "Command '%s' failed" % str(sender.cmdline()) - - receiver.wait() - assert receiver.status() == 0, "Command '%s' failed" % str(receiver.cmdline()) - - def test_server_authentication_messenger_app(self): - """ Test an SSL authentication using the Messenger apps. - """ - port = common.free_tcp_ports()[0] - - receiver = common.MessengerReceiverC() - receiver.subscriptions = ["amqps://~0.0.0.0:%s" % port] - receiver.receive_count = 1 - receiver.timeout = self.timeout - # Note hack - by default we use the client-certificate for the - # _server_ because the client-certificate's common name field - # is "127.0.0.1", which will match the target address used by - # the sender. - receiver.certificate = self._testpath("client-certificate.pem") - receiver.privatekey = self._testpath("client-private-key.pem") - receiver.password = "client-password" - receiver.start() - - sender = common.MessengerSenderC() - sender.targets = ["amqps://127.0.0.1:%s/X" % port] - sender.send_count = 1 - sender.timeout = self.timeout - sender.ca_db = self._testpath("ca-certificate.pem") - sender.start() - sender.wait() - assert sender.status() == 0, "Command '%s' failed" % str(sender.cmdline()) - - receiver.wait() - assert receiver.status() == 0, "Command '%s' failed" % str(receiver.cmdline()) - - def DISABLED_test_defaults_valgrind(self): - """ Run valgrind over a simple SSL connection (no certificates) - """ - # the openssl libraries produce far too many valgrind errors to be - # useful. AFAIK, there is no way to wriate a valgrind suppression - # expression that will ignore all errors from a given library. - # Until we can, skip this test. - port = common.free_tcp_ports()[0] - - receiver = common.MessengerReceiverValgrind() - receiver.subscriptions = ["amqps://~127.0.0.1:%s" % port] - receiver.receive_count = 1 - receiver.timeout = self.timeout - receiver.start() - - sender = common.MessengerSenderValgrind() - sender.targets = ["amqps://127.0.0.1:%s/X" % port] - sender.send_count = 1 - sender.timeout = self.timeout - sender.start() - sender.wait() - assert sender.status() == 0, "Command '%s' failed" % str(sender.cmdline()) - - receiver.wait() - assert receiver.status() == 0, "Command '%s' failed" % str(receiver.cmdline()) - - # self.server_domain.set_credentials(self._testpath("client-certificate.pem"), - # self._testpath("client-private-key.pem"), - # "client-password") - - # self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem")) - # self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER ) - def test_singleton(self): """Verify that only a single instance of SSL can exist per Transport""" transport = Transport() @@ -938,127 +851,3 @@ class SslTest(common.Test): except SSLException: pass -class MessengerSSLTests(common.Test): - - def setUp(self): - if not common.isSSLPresent(): - raise Skipped("No SSL libraries found.") - self.server = Messenger() - self.client = Messenger() - self.server.blocking = False - self.client.blocking = False - - def tearDown(self): - self.server.stop() - self.client.stop() - self.pump() - assert self.server.stopped - assert self.client.stopped - - def pump(self, timeout=0): - while self.client.work(0) or self.server.work(0): pass - self.client.work(timeout) - self.server.work(timeout) - while self.client.work(0) or self.server.work(0): pass - - def test_server_credentials(self, - cert="server-certificate.pem", - key="server-private-key.pem", - password="server-password", - exception=None): - import sys - # java doesn't do validation in the same way (yet) - if exception and "java" in sys.platform: - raise Skipped() - self.server.certificate = _testpath(cert) - self.server.private_key = _testpath(key) - self.server.password = password - port = common.free_tcp_ports()[0] - try: - self.server.start() - self.server.subscribe("amqps://~0.0.0.0:%s" % port) - if exception is not None: - assert False, "expected failure did not occur" - except MessengerException: - e = sys.exc_info()[1] - if exception: - assert exception in str(e), str(e) - else: - raise e - - def test_server_credentials_bad_cert(self): - self.test_server_credentials(cert="bad", - exception="invalid credentials") - - def test_server_credentials_bad_key(self): - self.test_server_credentials(key="bad", - exception="invalid credentials") - - def test_server_credentials_bad_password(self): - self.test_server_credentials(password="bad", - exception="invalid credentials") - - def test_client_credentials(self, - trusted="ca-certificate.pem", - cert="client-certificate.pem", - key="client-private-key.pem", - password="client-password", - altserv=False, - fail=False): - if altserv: - self.server.certificate = _testpath("bad-server-certificate.pem") - self.server.private_key = _testpath("bad-server-private-key.pem") - self.server.password = "server-password" - else: - self.server.certificate = _testpath("client-certificate.pem") - self.server.private_key = _testpath("client-private-key.pem") - self.server.password = "client-password" - self.server.start() - port = common.free_tcp_ports()[0] - self.server.subscribe("amqps://~0.0.0.0:%s" % port) - self.server.incoming_window = 10 - - self.client.trusted_certificates = _testpath(trusted) - self.client.certificate = _testpath(cert) - self.client.private_key = _testpath(key) - self.client.password = password - self.client.outgoing_window = 10 - self.client.start() - - self.server.recv() - - msg = Message() - msg.address = "amqps://127.0.0.1:%s" % port - # make sure a large, uncompressible message body works! - msg.body = "".join(random.choice(string.ascii_letters) - for x in range(10099)) - trk = self.client.put(msg) - self.client.send() - - self.pump() - - if fail: - assert self.server.incoming == 0, self.server.incoming - assert self.client.status(trk) == ABORTED, self.client.status(trk) - else: - assert self.server.incoming == 1, self.server.incoming - - rmsg = Message() - self.server.get(rmsg) - assert rmsg.body == msg.body - self.server.accept() - self.pump() - - assert self.client.status(trk) == ACCEPTED, self.client.status(trk) - - def test_client_credentials_bad_cert(self): - self.test_client_credentials(cert="bad", fail=True) - - def test_client_credentials_bad_trusted(self): - self.test_client_credentials(trusted="bad", fail=True) - - def test_client_credentials_bad_password(self): - self.test_client_credentials(password="bad", fail=True) - - def test_client_credentials_untrusted(self): - self.test_client_credentials(altserv=True, fail=True) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
